package com.lysh.http.utils;

import com.lysh.http.enums.ErrorMessage;
import com.lysh.http.exception.SDKException;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liyishan
 * @date 2023/4/19 12:50
 */

public class CheckUtils {
    public CheckUtils() {
    }

    public static void checkArgument(boolean expression, Integer code, String message) throws SDKException {
        if (!expression) {
            throw new SDKException(code, message);
        }
    }

    public static void checkArgument(boolean expression, ErrorMessage errorMessage, String message) throws SDKException {
        if (!expression) {
            if (StringUtils.isNotBlank(message)) {
                throw new SDKException(errorMessage.getCode(), message);
            } else {
                throw new SDKException(errorMessage.getCode(), errorMessage.getMessage());
            }
        }
    }
}
